home *** CD-ROM | disk | FTP | other *** search
/ Belgian Amiga Club - ADF Collection / BS1 part 05.zip / BS1 part 5 / SASC_6.0_Disk_7.adf / Source_And_Examples / examples / avg / README < prev    next >
Encoding:
Text File  |  1992-07-30  |  1.5 KB  |  35 lines

  1.  
  2.     Programming Example
  3.  
  4.       The sources avg.c and avg2.a are programming examples on how to setup 
  5.    and call
  6.    
  7.       -- assembler routines from C
  8.       -- AmigaDos routines from C
  9.       -- library routines from assembler routines
  10.       -- AmigaDos routines from assembler routines.
  11.      
  12.    In addition there is an example of how to create an assembler routine that
  13.    can be called with parameters passed on the stack as well as in register.
  14.    This feature allows you to have one routine that can be used whether you
  15.    compile with 'parms=stack' or 'parms=register'.   Also, you can create
  16.    C language routines with this same dual nature by using the 'parms=both'
  17.    option.  This is infact how we build our link libraries.
  18.  
  19.    To build the program compile and link the sources with the build line 
  20.    (sc avg.c avg2.a incdir=include: link) to produce an executable named 'avg'.
  21.    This program will accept numeric command line arguments and return for you
  22.    the average of the numeric values.  To do this it uses two assembler 
  23.    routines (avg() and prnts()) to compute and print the average.   avg() is
  24.    the routine that is built to handle both stack and register parameters.
  25.    prnts() is calls the AmigaDos Write() routine to write to the console.
  26.    If no arguments are given, the program returns a usage message.
  27.    
  28.    Ex: 1> avg 1 2 3
  29.        average = 2
  30.        
  31.    As with all our examples, feel free to experiment with different compilation
  32.    options and startups.  In the sources themselves are some hints as to the
  33.    different things that you can try.
  34.    
  35.